package com.xifly.jwt.repository;

import com.xifly.jwt.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;

public interface UserRepository extends JpaRepository<User, Long>{

    User findByUsername(String name);

    @Modifying
    @Query("update User set lastLoginTime = :lastLoginTime where username =:username")
    void updateLastLoginTimeByUserName(@Param("lastLoginTime")Date lastLoginTime, @Param("username")String username);
}
